#!/bin/bash

#ly 2018-7-27


checkPythonVersion()
{
   V1=3333
   echo $V1
}


echo -e "\033[32m 开始安装python3 \033[0m"

#安装python依赖

yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
echo -e "\033[32m python依赖安装success \033[0m"

version=`python --version`
echo $version
checkPythonVersion
exit
#安装python3.7

echo -e "\033[32m 开始安装python3.7 \033[0m"
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
tar -xvJf  Python-3.7.0.tar.xz
cd Python-3.7.0 && ./configure prefix=/usr/local/python3 && make && make install
echo -e "\033[32m python3 安装成功 \033[0m"
exit

#python2.7 备份

echo -e "\033[32m python2.7开始备份 \033[0m"
mv /usr/bin/python /usr/bin/python2.7.bak
echo -e "\033[32m python2.7备份成功 \033[0m"

echo -e "\033[32m python3 开始创建软链接 \033[0m"
ln -s /usr/local/python3/bin/python3 /usr/bin/python
echo -e "\033[32m python3 创建软链接成功 \033[0m"



echo -e "\033[32m python3 安装成功 \033[0m"
